import request from '@/utils/request'

// 获取设备统计数量
export function countEquipment() {
  return request({
    url: '/equipment/main/countEquipment',
    method: 'get',
  })
}

// 获取设备类型列表
export function listEquipmentTypes() {
  return request({
    url: '/equipment/type/list',
    method: 'get',
  })
}

// 获取设备列表
export function listEquipment(params) {
  return request({
    url: '/equipment/main/list',
    method: 'get',
    params,
  })
}

// 删除设备
export function deleteEquipment(id) {
  return request({
    url: `/equipment/main/remove/${id}`,
    method: 'get',
  })
}

// 新增设备
export function addEquipment(data) {
  return request({
    url: '/equipment/main/add',
    method: 'post',
    data: data,
  })
}

// 获取设备详情
export function getEquipment(id) {
  return request({
    url: `/equipment/main/getInfo/${id}`,
    method: 'get',
  })
}

// 修改设备
export function updateEquipment(data) {
  return request({
    url: '/equipment/main/edit',
    method: 'post',
    data: data,
  })
}

// 添加维修记录
export function addRepairHistory(data) {
  return request({
    url: '/equipment/repairHistory/add',
    method: 'post',
    data: data,
  })
}

// 获取最新维修记录
export function getNewestRepairHistory(id) {
  return request({
    url: `/equipment/repairHistory/getNewest/${id}`,
    method: 'get',
  })
}

// 添加调拨记录
export function addTransferRecord(data) {
  return request({
    url: '/equipment/transferRecords/add',
    method: 'post',
    data: data,
  })
}

// 获取维修记录列表
export function getRepairHistoryList(query) {
  return request({
    url: '/equipment/repairHistory/list',
    method: 'get',
    params: query,
  })
}

// 获取调拨记录列表
export function getTransferRecordsList(query) {
  return request({
    url: '/equipment/transferRecords/list',
    method: 'get',
    params: query,
  })
}
